import request from '@/utils/request'

export const getRoleList = (page = 1, pagesize = 10) => request.get('/sys/role', {
  params: {
    page,
    pagesize
  }
})

export const addRole = form => {
  return request({
    url: '/sys/role',
    method: 'post',
    data: form
  })
}

export const delRole = id => request.delete('/sys/role/' + id)

export const editRole = (data) => request.put(`/sys/role/${data.id}`, data)

// 获取已启用的角色列表
export const getEnabledRoleList = () => request.get('/sys/role/list/enabled')

export const getRoleDetail = (id) => request.get(`/sys/role/${id}`)

export const assignPerm = (id, permIds) => request.put('/sys/role/assignPrem', {
  id,
  permIds
})
